﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ADDDF.Infrastructure.ChangeTracking.ChangeRecords
{
    class EntityKeyEqualityComparer : IEqualityComparer<EntityKey>
    {
        public bool Equals(EntityKey x, EntityKey y)
        {
            if (!x.Type.Equals(y.Type))
                return false;

            if (x.Key == null)
            {
                if (y.Key != null)
                    return false;
            }
            else if (y.Key == null)
            {
                if (x.Key != null)
                    return false;
            }
            else
            {
                if (!x.Key.Equals(y.Key))
                    return false;
            }

            return true;
        }

        public int GetHashCode(EntityKey obj)
        {
            return obj.GetHashCode();
        }
    }
}
